import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:get/get_state_manager/src/simple/get_view.dart';
import 'package:getwidget/getwidget.dart';
import 'package:isolate_manager/isolate_manager.dart';
import 'package:syncfusion_flutter_datepicker/datepicker.dart';

import '../../app_pages.dart';
import '../controller.dart';
import 'home_page_appbar.dart';

class HomePageWidget extends GetView<HomePageController> {
  const HomePageWidget({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: HomePageAppbar(),
      body: Column(
        children: [
          GFButton(
            text: "页面加粉上、下号",
            fullWidthButton: true,
            onPressed: () {
              Get.toNamed(AppRoutes.WathsappJumpLinkPage, arguments: {});
            },
          ).marginOnly(left: 15, right: 15),
          GFButton(
            text: "批量查粉",
            fullWidthButton: true,
            onPressed: () {
              Get.toNamed(AppRoutes.QueryFansPage, arguments: {});
            },
          ).marginOnly(left: 15, right: 15),
          GFButton(
              text: "测试",
              fullWidthButton: true,
              onPressed: () async {
                final isolateShared = IsolateManager.createShared(
                    concurrent: 2,
                    useWorker: true,
                    workerMappings: {
                      fibonacci: 'fibonacci',
                    });

                final result = await isolateShared.compute(
                  fibonacci,
                  20,
                );
                print(result);
              }).marginOnly(left: 15, right: 15),
        ],
      ),
    );
  }
}

@isolateManagerWorker // Add this anotation
int fibonacci(int n) {
  return n + 1;
}
